<template>
    <div>
        <div class="warp">
            <BreadCrumb></BreadCrumb>
        </div>
        <h1>学生期末考试成绩录入</h1>
        <el-form ref="form" :model="form" label-width="130px">
            <el-form-item label="学号:">
                <el-input v-model="form.stu_id"></el-input>
            </el-form-item>
            <el-form-item label="姓名:">
                <el-input v-model="form.stu_name"></el-input>
            </el-form-item>
            <el-form-item label="语文:">
                <el-input v-model="form.chinese"></el-input>
            </el-form-item>
            <el-form-item label="数学:">
                <el-input v-model="form.math"></el-input>
            </el-form-item>
            <el-form-item label="英语:">
                <el-input v-model="form.english"></el-input>
            </el-form-item>
            <el-form-item label="理综:">
                <el-input v-model="form.lizong"></el-input>
            </el-form-item>
            <el-form-item label="文综:">
                <el-input v-model="form.wenzong"></el-input> 
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="onSubmit">提交</el-button>
                <el-button type="primary" @click="onReset">重置</el-button>

            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import { req_end_exam } from "@/api/stuInfo";
export default {
    data(){
        return{
            form:{
                stu_id: '',
                stu_name: '',
                chinese: '',
                math: '',
                english: '',
                stu_hobby: '',
                lizong: '',
                wenzong: '',
            }
        }
    },

    async mounted(){
        let result = await req_end_exam();
        console.log(result);
    },
    methods:{
        async onSubmit() {
            console.log('submit!');
            console.log(this.form);
            let result = await req_end_exam(this.form);
            console.log(result);
            this.$message({
                message: '数据提交成功',
                type: 'success',
                offset: 100,
            })
        },
        onReset() {
            console.log('重置');
            this.$nextTick(()=>{
                this.$refs.form.resetFields();
            });
            this.form.stu_id = '';
            this.form.stu_name = '';
        },
    }
}
</script>

<style lang="scss" scoped>

</style>